package org.duang.db.sql.parser.encode;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.duang.db.mongo.Operator;
import org.duang.db.sql.SqlObject;
import org.duang.db.sql.parser.SqlEncodeConvetor;
import org.duang.kit.ToolsKit;

import com.mongodb.DBObject;

public class SqlCollectionEncoder extends SqlEncoder {
	

	public SqlCollectionEncoder(String key, String opt, Object obj) {
		super(key, opt, obj);
	}


	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public List<SqlObject> getValue() {
		Collection colls = (Collection) obj;
		List<SqlObject> sqlObjectList = new ArrayList<SqlObject>();
		for(Iterator<Collection> it = colls.iterator(); it.hasNext();){
			DBObject dbo = (DBObject)it.next();
			sqlObjectList.addAll(SqlEncodeConvetor.parser(key, key, dbo).getValue());
		}
		return sqlObjectList;
	}

}
